﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;

namespace XSot.BitBrowser.LocalApiClient.Model
{
    public class BitBrowserProfile
    {
        /// <summary>
        /// 唯一标识
        /// </summary>
        [JsonProperty("id")]
        public string Id { get; set; } = string.Empty;
        /// <summary>
        /// 序列号（创建无效）
        /// </summary>
        [JsonProperty("seq")]
        public int Seq { get; set; }
        /// <summary>
        /// 代码
        /// </summary>
        [JsonProperty("code")]
        public string? Code { get; set; }
        /// <summary>
        /// 分组编号，创建的时候，如果没有指定分组 ID，则系统会默认创建一个 API 分组，并把窗口分配到 API 分组里
        /// </summary>
        [JsonProperty("groupId")]
        public string? GroupId { get; set; }
        /// <summary>
        /// 账号平台
        /// </summary>
        [JsonProperty("platform")]
        public string? Platform { get; set; }
        /// <summary>
        /// 平台图标
        /// </summary>
        [JsonProperty("platformIcon")]
        public string? PlatformIcon { get; set; }
        /// <summary>
        /// 打开的网站
        /// </summary>
        [JsonProperty("url")]
        public string? Url { get; set; }
        /// <summary>
        /// 窗口名称
        /// </summary>
        [JsonProperty("name")]
        public string? Name { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        [JsonProperty("userName")]
        public string? Username { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        [JsonProperty("password")]
        public string? Password { get; set; }
        /// <summary>
        /// Cookie
        /// </summary>
        [JsonProperty("cookie")]
        public string? Cookie { get; set; }
        /// <summary>
        /// 其他 Cookie
        /// </summary>
        [JsonProperty("otherCookie")]
        public string? OtherCookie { get; set; }
        /// <summary>
        /// 是否全局代理信息
        /// </summary>
        [JsonProperty("isGlobalProxyInfo")]
        public bool IsGlobalProxyInfo { get; set; } = false;
        /// <summary>
        /// 是否 IPv6
        /// </summary>
        [JsonProperty("isIpv6")]
        public bool IsIpv6 { get; set; } = false;
        /// <summary>
        /// 代理方法
        /// </summary>
        [JsonProperty("proxyMethod")]
        public int ProxyMethod { get; set; } = 2;
        /// <summary>
        /// 代理类型 ['noproxy', 'http', 'https', 'socks5', 'ssh']中一个，默认 noproxy，直连模式
        /// </summary>
        [JsonProperty("proxyType")]
        public string? ProxyType { get; set; }
        /// <summary>
        /// 代理 ID
        /// </summary>
        [JsonProperty("agentId")]
        public string? AgentId { get; set; }
        /// <summary>
        /// IP 检查服务，默认 ip123in
        /// </summary>
        [JsonProperty("ipCheckService")]
        public string? IpCheckService { get; set; }
        /// <summary>
        /// 代理主机
        /// </summary>
        [JsonProperty("host")]
        public string? Host { get; set; }
        /// <summary>
        /// 代理端口
        /// </summary>
        [JsonProperty("port")]
        public int Port { get; set; }
        /// <summary>
        /// 代理用户名
        /// </summary>
        [JsonProperty("proxyUserName")]
        public string? ProxyUserName { get; set; }
        /// <summary>
        /// 代理密码
        /// </summary>
        [JsonProperty("proxyPassword")]
        public string? ProxyPassword { get; set; }
        /// <summary>
        /// 上次 IP
        /// </summary>
        [JsonProperty("lastIp")]
        public string? LastIp { get; set; }
        /// <summary>
        /// 上次国家
        /// </summary>
        [JsonProperty("lastCountry")]
        public string? LastCountry { get; set; }
        /// <summary>
        /// 是否 IP 未变化
        /// </summary>
        [JsonProperty("isIpNoChange")]
        public bool? IsIpNoChange { get; set; }
        /// <summary>
        /// 当前 IP
        /// </summary>
        [JsonProperty("ip")]
        public string? Ip { get; set; }
        /// <summary>
        /// 当前国家
        /// </summary>
        [JsonProperty("country")]
        public string? Country { get; set; }
        /// <summary>
        /// 当前省份
        /// </summary>
        [JsonProperty("province")]
        public string? Province { get; set; }
        /// <summary>
        /// 当前城市
        /// </summary>
        [JsonProperty("city")]
        public string? City { get; set; }
        /// <summary>
        /// 动态 IP URL
        /// </summary>
        [JsonProperty("dynamicIpUrl")]
        public string? DynamicIpUrl { get; set; }
        /// <summary>
        /// 是否动态 IP 变化
        /// </summary>
        [JsonProperty("isDynamicIpChangeIp")]
        public bool IsDynamicIpChangeIp { get; set; } = false;
        /// <summary>
        /// 备注
        /// </summary>
        [JsonProperty("remark")]
        public string? Remark { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        [JsonProperty("status")]
        public int? Status { get; set; }
        /// <summary>
        /// 操作用户名
        /// </summary>
        [JsonProperty("operUserName")]
        public string? OperUserName { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        [JsonProperty("isDelete")]
        public int IsDelete { get; set; } = 0;
        /// <summary>
        /// 删除原因
        /// </summary>
        [JsonProperty("delReason")]
        public string? DelReason { get; set; }
        /// <summary>
        /// 是否最常用
        /// </summary>
        [JsonProperty("isMostCommon")]
        public int? IsMostCommon { get; set; }
        /// <summary>
        /// 是否移除
        /// </summary>
        [JsonProperty("isRemove")]
        public int? IsRemove { get; set; }
        /// <summary>
        /// 临时字符串
        /// </summary>
        [JsonProperty("tempStr")]
        public string? TempStr { get; set; }
        /// <summary>
        /// 创建者
        /// </summary>
        [JsonProperty("createdBy")]
        public string? CreatedBy { get; set; }
        /// <summary>
        /// 用户 ID
        /// </summary>
        [JsonProperty("userId")]
        public string? UserId { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        [JsonProperty("createdTime")]
        public DateTime? CreatedTime { get; set; }
        /// <summary>
        /// 回收站备注
        /// </summary>
        [JsonProperty("recycleBinRemark")]
        public string? RecycleBinRemark { get; set; }
        /// <summary>
        /// 主用户 ID
        /// </summary>
        [JsonProperty("mainUserId")]
        public string? MainUserId { get; set; }
        /// <summary>
        /// 是否中止图片加载
        /// </summary>
        [JsonProperty("abortImage")]
        public bool? AbortImage { get; set; } = false;
        /// <summary>
        /// 是否中止媒体加载
        /// </summary>
        [JsonProperty("abortMedia")]
        public bool? AbortMedia { get; set; } = false;
        /// <summary>
        /// 网络错误时停止
        /// </summary>
        [JsonProperty("stopWhileNetError")]
        public bool? StopWhileNetError { get; set; } = false;
        /// <summary>
        /// 国家变化时停止
        /// </summary>
        [JsonProperty("stopWhileCountryChange")]
        public bool? StopWhileCountryChange { get; set; } = false;
        /// <summary>
        /// 同步标签页
        /// </summary>
        [JsonProperty("syncTabs")]
        public bool? SyncTabs { get; set; } = true;
        /// <summary>
        /// 同步 Cookies
        /// </summary>
        [JsonProperty("syncCookies")]
        public bool? SyncCookies { get; set; } = true;
        /// <summary>
        /// 同步 IndexedDB
        /// </summary>
        [JsonProperty("syncIndexedDb")]
        public bool? SyncIndexedDb { get; set; } = false;
        /// <summary>
        /// 同步书签
        /// </summary>
        [JsonProperty("syncBookmarks")]
        public bool? SyncBookmarks { get; set; } = false;
        /// <summary>
        /// 同步授权信息
        /// </summary>
        [JsonProperty("syncAuthorization")]
        public bool? SyncAuthorization { get; set; } = false;
        /// <summary>
        /// 同步历史记录
        /// </summary>
        [JsonProperty("syncHistory")]
        public bool? SyncHistory { get; set; } = false;
        /// <summary>
        /// 同步 Google 账户
        /// </summary>
        [JsonProperty("syncGoogleAccount")]
        public bool? SyncGoogleAccount { get; set; } = true;
        /// <summary>
        /// 允许登录
        /// </summary>
        [JsonProperty("allowedSignin")]
        public bool? AllowedSignin { get; set; } = false;
        /// <summary>
        /// 同步会话
        /// </summary>
        [JsonProperty("syncSessions")]
        public bool? SyncSessions { get; set; } = true;
        /// <summary>
        /// 工作台 本地:workbench，不显示:disable
        /// </summary>
        [JsonProperty("workbench")]
        public string? Workbench { get; set; } = "localserver";
        /// <summary>
        /// 启动前清除缓存文件
        /// </summary>
        [JsonProperty("clearCacheFilesBeforeLaunch")]
        public bool? ClearCacheFilesBeforeLaunch { get; set; } = false;
        /// <summary>
        /// 启动前清除 Cookies
        /// </summary>
        [JsonProperty("clearCookiesBeforeLaunch")]
        public bool? ClearCookiesBeforeLaunch { get; set; } = false;
        /// <summary>
        /// 启动前清除历史记录
        /// </summary>
        [JsonProperty("clearHistoriesBeforeLaunch")]
        public bool? ClearHistoriesBeforeLaunch { get; set; } = false;
        /// <summary>
        /// 随机指纹
        /// </summary>
        [JsonProperty("randomFingerprint")]
        public bool? RandomFingerprint { get; set; } = false;
        /// <summary>
        /// 静音
        /// </summary>
        [JsonProperty("muteAudio")]
        public bool? MuteAudio { get; set; } = false;
        /// <summary>
        /// 禁用 GPU
        /// </summary>
        [JsonProperty("disableGpu")]
        public bool? DisableGpu { get; set; } = false;
        /// <summary>
        /// 启用后台模式
        /// </summary>
        [JsonProperty("enableBackgroundMode")]
        public bool? EnableBackgroundMode { get; set; } = false;
        /// <summary>
        /// 中止图片最大尺寸
        /// </summary>
        [JsonProperty("abortImageMaxSize")]
        public int? AbortImageMaxSize { get; set; }
        /// <summary>
        /// 同步扩展
        /// </summary>
        [JsonProperty("syncExtensions")]
        public bool? SyncExtensions { get; set; } = false;
        /// <summary>
        /// 同步用户扩展
        /// </summary>
        [JsonProperty("syncUserExtensions")]
        public bool? SyncUserExtensions { get; set; } = false;
        /// <summary>
        /// 同步本地存储
        /// </summary>
        [JsonProperty("syncLocalStorage")]
        public bool? SyncLocalStorage { get; set; } = false;
        /// <summary>
        /// 启用凭证服务
        /// </summary>
        [JsonProperty("credentialsEnableService")]
        public bool? CredentialsEnableService { get; set; } = false;
        /// <summary>
        /// 禁用翻译弹窗
        /// </summary>
        [JsonProperty("disableTranslatePopup")]
        public bool? DisableTranslatePopup { get; set; } = false;
        /// <summary>
        /// IP 变化时停止
        /// </summary>
        [JsonProperty("stopWhileIpChange")]
        public bool? StopWhileIpChange { get; set; } = false;
        /// <summary>
        /// 禁用剪贴板
        /// </summary>
        [JsonProperty("disableClipboard")]
        public bool? DisableClipboard { get; set; } = false;
        /// <summary>
        /// 禁用通知
        /// </summary>
        [JsonProperty("disableNotifications")]
        public bool? DisableNotifications { get; set; } = false;
        /// <summary>
        /// 内存节省模式
        /// </summary>
        [JsonProperty("memorySaver")]
        public bool? MemorySaver { get; set; } = false;
        /// <summary>
        /// 创建者名称
        /// </summary>
        [JsonProperty("createdName")]
        public string? CreatedName { get; set; }
        /// <summary>
        /// 所属用户名
        /// </summary>
        [JsonProperty("belongUserName")]
        public string? BelongUsername { get; set; }
        /// <summary>
        /// 更新者名称
        /// </summary>
        [JsonProperty("updateName")]
        public string? UpdateName { get; set; }
        /// <summary>
        /// 代理 IP 数量
        /// </summary>
        [JsonProperty("agentIpCount")]
        public int? AgentIpCount { get; set; }
        /// <summary>
        /// 是否属于我
        /// </summary>
        [JsonProperty("belongToMe")]
        public bool? BelongToMe { get; set; } = false;
        /// <summary>
        /// 导出序列号
        /// </summary>
        [JsonProperty("seqExport")]
        public int? SeqExport { get; set; }
        /// <summary>
        /// 组 ID 列表
        /// </summary>
        [JsonProperty("groupIDs")]
        public List<string>? GroupIDs { get; set; }
        /// <summary>
        /// 浏览器共享 ID
        /// </summary>
        [JsonProperty("browserShareID")]
        public string? BrowserShareID { get; set; }
        /// <summary>
        /// 共享信息
        /// </summary>
        [JsonProperty("share")]
        public string? Share { get; set; }
        /// <summary>
        /// 共享用户名
        /// </summary>
        [JsonProperty("shareUserName")]
        public string? ShareUserName { get; set; }
        /// <summary>
        /// 是否共享
        /// </summary>
        [JsonProperty("isShare")]
        public int? IsShare { get; set; } = 0;
        /// <summary>
        /// 是否有效用户名
        /// </summary>
        [JsonProperty("isValidUsername")]
        public bool? IsValidUsername { get; set; } = false;
        /// <summary>
        /// 创建数量
        /// </summary>
        [JsonProperty("createNum")]
        public int? CreateNum { get; set; } = 0;
        /// <summary>
        /// 是否随机指纹
        /// </summary>
        [JsonProperty("isRandomFinger")]
        public bool? IsRandomFinger { get; set; } = true;
        /// <summary>
        /// 备注类型
        /// </summary>
        [JsonProperty("remarkType")]
        public int? RemarkType { get; set; } = 1;
        /// <summary>
        /// 刷新代理 URL
        /// </summary>
        [JsonProperty("refreshProxyUrl")]
        public string? RefreshProxyUrl { get; set; }
        /// <summary>
        /// 重复检查
        /// </summary>
        [JsonProperty("duplicateCheck")]
        public int? DuplicateCheck { get; set; } = 0;
        /// <summary>
        /// OSS 扩展
        /// </summary>
        [JsonProperty("ossExtend")]
        public string? OssExtend { get; set; }
        /// <summary>
        /// 随机键
        /// </summary>
        [JsonProperty("randomKey")]
        public string? RandomKey { get; set; }
        /// <summary>
        /// 用户随机键
        /// </summary>
        [JsonProperty("randomKeyUser")]
        public string? RandomKeyUser { get; set; }
        /// <summary>
        /// 同步浏览器账户
        /// </summary>
        [JsonProperty("syncBrowserAccount")]
        public string? SyncBrowserAccount { get; set; }
        /// <summary>
        /// Cookie 备份
        /// </summary>
        [JsonProperty("cookieBak")]
        public string? CookieBak { get; set; }
        /// <summary>
        /// 密码备份
        /// </summary>
        [JsonProperty("passwordBak")]
        public string? PasswordBak { get; set; }
        /// <summary>
        /// 手动操作
        /// </summary>
        [JsonProperty("manual")]
        public int? Manual { get; set; } = 0;
        /// <summary>
        /// 代理密码备份
        /// </summary>
        [JsonProperty("proxyPasswordBak")]
        public string? ProxyPasswordBak { get; set; }
        /// <summary>
        /// 代理协议类型
        /// </summary>
        [JsonProperty("proxyAgreementType")]
        public string? ProxyAgreementType { get; set; }
        /// <summary>
        /// 清除缓存但不包括扩展
        /// </summary>
        [JsonProperty("clearCacheWithoutExtensions")]
        public bool? ClearCacheWithoutExtensions { get; set; } = false;
        /// <summary>
        /// 同步支付和地址
        /// </summary>
        [JsonProperty("syncPaymentsAndAddress")]
        public bool? SyncPaymentsAndAddress { get; set; } = false;
        /// <summary>
        /// 扩展 ID 列表
        /// </summary>
        [JsonProperty("extendIds")]
        public List<string> ExtendIds { get; set; } = new List<string>();
        /// <summary>
        /// 是否同步开启
        /// </summary>
        [JsonProperty("isSynOpen")]
        public int? IsSynOpen { get; set; } = 1;
        /// <summary>
        /// FA 密钥
        /// </summary>
        [JsonProperty("faSecretKey")]
        public string? FaSecretKey { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        [JsonProperty("sort")]
        public int? Sort { get; set; } = 0;
        /// <summary>
        /// 检查密码
        /// </summary>
        [JsonProperty("checkPassword")]
        public string? CheckPassword { get; set; }
        /// <summary>
        /// 浏览器内核（chrome | firefox，默认chrome，需要火狐内核时，填firefox）
        /// </summary>
        [JsonProperty("coreProduct")]
        [JsonConverter(typeof(StringEnumConverter))]
        public BitBrowserCoreProduct CoreProduct { get; set; } = BitBrowserCoreProduct.Chrome;
        /// <summary>
        /// 操作系统平台 PC | Android | IOS
        /// </summary>
        [JsonProperty("ostype")]
        [JsonConverter(typeof(StringEnumConverter))]
        public BitBrowserOSType OSType { get; set; } = BitBrowserOSType.PC;
        /// <summary>
        /// navigator.platform值，严格与操作系统一一对应, Windows => Win32, macOS => MacIntel, Linux => Linux x86_64, iOS => iPhone, Android => Linux armv81
        /// </summary>
        [JsonProperty("os")]
        [JsonConverter(typeof(StringEnumConverter))]
        public BitBrowserOS OS { get; set; } = BitBrowserOS.Windows;
        /// <summary>
        /// 浏览器的指纹
        /// </summary>
        [JsonProperty("browserFingerPrint")]
        public BitBrowserFingerPrint? FingerPrint { get; set; }

        public override string ToString()
        {
            return $"name:{Name},id:{Id},seq:{Seq}";
        }
    }
}